package com.ibm.csr.staf;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class EnvManager {

	File configFile;
	Properties p;

	public EnvManager() throws Exception {
		String path = (EnvManager.class.getResource("/").getPath() + "staf-env.properties");
		this.configFile = new File(path);
		init(configFile);
	}

	public EnvManager(File config) throws Exception {
		init(config);
	}

	public EnvManager init(File config) throws Exception {
		p = new Properties();
		FileInputStream inStream;
		try {
			inStream = new FileInputStream(config);
			p.load(inStream);
			inStream.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			throw e;
		} catch (IOException e) {
			e.printStackTrace();
			throw e;
		}
		return this;
	}

	public String get(String key) {
		String v = (String) p.get(key);
		return v;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		MSGLog.log(System.getProperty("JCC_LIB"));
	}

}
